import { Router, Route, Redirect } from 'react-router-dom'
// 导入页面组件
import Login from '@/pages/Login/Login'
import Layout from '@/pages/Layout/Layout'
import ProfileEdit from './pages/Profile/Edit'
import history from './utils/history'
import './App.scss'
import { PrivateRoute } from './components/PrivateRoute'
import Chat from './pages/Profile/Chat'
import Search from './pages/Search/Search'
import Result from './pages/Search/Result/Result'
import Article from './pages/Article/Article'
import KeepAlive from './components/Keepalive/Keepalive'
// 配置路由规则
function App () {
  return (
    <Router history={history}>
      <div className="app">
        <Route path='/' exact render={() => <Redirect to="/home"/>} />

        {/* <Route path="/home" component={Layout}></Route> */}
        <KeepAlive path="/home">
          <Layout/>
        </KeepAlive>
        <Route path="/login"><Login /></Route>
        <Route path="/profile/edit">
          <ProfileEdit />
        </Route>
        <PrivateRoute path="/chat">
          <Chat/>
        </PrivateRoute>
        <Route path="/article/:id">
            <Article/>
        </Route>

        <Route exact path="/search">
            <Search></Search>
        </Route>
        <Route exact path="/search/result">
            <Result />
        </Route>
      </div>
    </Router>
  )
}

export default App
